import request from "@/utils/request";

const LOG_BASE_URL = "/v3/data/deviceAlarm";

class deviceAlarmApi {



  // 标记处理
  static batchHandingAlarm(data: HandingAlarm[]) {
    return request({
      url: `${LOG_BASE_URL}/batchHandingAlarm`,
      method: "post",
      data: data,
      headers: {
        "Content-Type": "application/json",
      }
    });
  }

  // 告警列表
  static selectByPage(data: SelectByPageParams) {
    return request<any,Alarmtype>({
      url: `${LOG_BASE_URL}/selectByPage`,
      method: "post",
      data: data,
      headers: {
        "Content-Type": "application/json",
      }
    });
  }

// 今日告警
  static gettodayAlarm(Params: todayDataAlarm) {
    return request<any,AlarmData[]>({
      url: `${LOG_BASE_URL}/todayData`,
      method: "get",
      params: Params,
    });
  }
  
  static getDeviceAlarm(Params: DeviceAlarm) {
    return request<any,DeviceAlarmlist>({
      url: `${LOG_BASE_URL}/getDeviceAlarm`,
      method: "get",
      params: Params,
    });
  }

}

export default deviceAlarmApi;

export interface AlarmData {
  id: string;
  deviceId: number;
  alarmCode: string;
  count: number;
  status: string; // 可以根据需要扩展状态
  latestAlarmTime: string; // 可以考虑使用 Date 类型
  createTime: string; // 同样可以考虑使用 Date 类型
  deviceCode: string;
  towerNumber: string;
  alarmName: string;
}
export interface HandingAlarm {
  deviceTypeCode: string;
  id:string;
}
export interface DeviceAlarm {
  deviceId: string;
}
interface todayDataAlarm{
  isChild:boolean
}

export interface DeviceAlarmlist {
    // current: number;
    statistics: Array<DeviceAlarmTO>;
    data: Array<any>
    // size: number;
    // total: number
}

export interface DeviceAlarmTO {
  name: string;
  count: number;
  
}

export interface Alarmtype{
  "data": [
      {
          "id": string,
          "deviceId": string,
          "alarmCode": string,
          "count": number,
          "status": string,
          "latestAlarmTime": string,
          "createTime": string,
          "deviceCode": string,
          "towerNumber": string,
          "alarmName"?: string

      }
  ],
  "total": number,
  "size": number,
  "current": number
}

// 参数接口
export interface SelectByPageParams {
  /* */
  pages: {
    total:number;
    /* */
    current: number;

    /* */
    size:number;

    /* */
    startTime?: string;

    /* */
    endTime?: string;

    /* */
    orders?: {
      /* */
      column?: string;

      /* */
      asc?: boolean;
    }[];
  };
  deviceCode?:string;
  towerNumber?:string;
  count?:string;
  alarmName?:string;
  alarmCode?:string;
  /* */
  keyWord?: string;
  customerId?:string;

  /* */

  /*可用值:UNPROCESSED,PROCESSED */
  status?: string;

  /* */
  child?: boolean;
}


// {
//   {
//     "pages": {
//       current:string;
//       "size": 0,
//       "startTime": "",
//       "endTime": "",
//       "orders": [
//         {
//           "column": "",
//           "asc": true
//         }
//       ]
//     },
//     "keyWord": "",
//     "alarmCode": "",
//     "status": "",
//     "child": true
//   }
// }